﻿using Ct.StudentProject.Data;
using Ct.StudentProject.Myself;
using System;
using CtCommon.Utility;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication3
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string JsonText = Console.ReadLine();
            student user = JsonText.JSONDeserialize<student>();
            try
            {

                string msg = string.Empty;
                Deliver del = new Deliver();

                bool isvaild = del.VerifyAndDeliver(user, out msg);

                if (isvaild)
                {
                    // MessageBox.Show(msg);
                    Console.WriteLine(msg);
                }
                else
                {
                    msg = string.Empty;
                    StudentDatabase db = new StudentDatabase();
                    if (db.InsertStudent(user, out msg) == true)
                    {
                        //MessageBox.Show("ID为" + msg);
                        Console.WriteLine("ID为" + msg);
                    }
                }

            }
            catch
            {

            }
        }
    }
}